package com.xiaocg.sparse.test;

public class ArraySquence {

    public static void main(String[] args) {
        int[] arr1 = new int[]{1,2,4,8,9};
        int[] arr2 = new int[]{3,5,6,7,9,10,13};
        int[] temp = new int[arr1.length+arr2.length];
        int i=0;
        int j=0;
        int k=0;
        while (i<arr1.length&&j<arr2.length){
            if (arr1[i]<=arr2[j]){
                temp[k++] = arr1[i++];
            }else{
                temp[k++] = arr2[j++];
            }
        }

        if (j==arr2.length){
            for (int l = i; l < arr1.length; l++) {
                temp[k++] = arr1[l];
            }
        }

        if (i==arr1.length){
            for (int l = j; l < arr2.length; l++) {
                temp[k++] = arr2[l];
            }
        }

        for (int l = 0; l < temp.length; l++) {
            System.out.print(temp[l]+" ");
        }


    }


}
